From: Adrian Vovk Date: Fri, 27 Feb 2026 20:58:17 +0000 (-0500) Subject: systemActions: Switch to updated CanShutdown() API X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~26^2~1^2~24 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=9764ddf8b2575164449363a0b45cf38ad88478d6;p=gnome-shell.git systemActions: Switch to updated CanShutdown() API There's corresponding changes in gnome-session that report more detail about the availability of the action. This allows gnome-shell to appropriately hide the action whenever it is inhibited, and would lead to a Polkit prompt. Part-of: --- diff --git a/data/dbus-interfaces/org.gnome.SessionManager.xml b/data/dbus-interfaces/org.gnome.SessionManager.xml index c81c90f08..74a3a2e55 100644 --- a/data/dbus-interfaces/org.gnome.SessionManager.xml +++ b/data/dbus-interfaces/org.gnome.SessionManager.xml @@ -6,7 +6,7 @@ - + diff --git a/js/misc/gnomeSession.js b/js/misc/gnomeSession.js index 218250429..45526c74b 100644 --- a/js/misc/gnomeSession.js +++ b/js/misc/gnomeSession.js @@ -62,3 +62,10 @@ export const InhibitFlags = { IDLE: 1 << 3, AUTOMOUNT: 1 << 4, }; + +export const ActionAvailability = { + UNAVAILABLE: 0, + BLOCKED: 1, + CHALLENGE: 2, + AVAILABLE: 3, +}; diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js index 710d42fa5..eb358e37a 100644 --- a/js/misc/systemActions.js +++ b/js/misc/systemActions.js @@ -82,6 +82,7 @@ const SystemActions = GObject.registerClass({ super._init(); this._canHavePowerOff = true; + this._powerOffNeedsAuth = false; this._canHaveSuspend = true; function tokenizeKeywords(keywords) { @@ -345,10 +346,12 @@ const SystemActions = GObject.registerClass({ async _updateHaveShutdown() { try { - const [canShutdown] = await this._session.CanShutdownAsync(); - this._canHavePowerOff = canShutdown; + const [availability] = await this._session.CanShutdownAsync(); + this._canHavePowerOff = availability !== GnomeSession.ActionAvailability.UNAVAILABLE; + this._powerOffNeedsAuth = availability === GnomeSession.ActionAvailability.CHALLENGE; } catch { this._canHavePowerOff = false; + this._powerOffNeedsAuth = false; } this._updatePowerOff(); } @@ -356,6 +359,7 @@ const SystemActions = GObject.registerClass({ _updatePowerOff() { const disabled = (Main.sessionMode.isLocked && !this._screenSaverSettings.get_boolean(RESTART_ENABLED_KEY)) || + (Main.sessionMode.isLocked && this._powerOffNeedsAuth) || (Main.sessionMode.isGreeter && this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY)); this._actions.get(POWER_OFF_ACTION_ID).available = this._canHavePowerOff && !disabled;